/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: COFFEEWEN
 * Date: 2022-08-21
 * Time: 18:58
 */
public class Test {
    public static int strStr(String haystack, String needle) {
        if (haystack == null || needle == null ){
            return -1;
        }
        if (haystack.length() < needle.length()){
            return -1;
        }
        char[] ch1 = haystack.toCharArray();
        char[] p = needle.toCharArray();
        int i = 0;
        int j = 0;
        int ps = 0;
        while (ps < ch1.length){
            i = ps;;
            j = 0;
            while (ch1[i] == p[j]){
                if (i<ch1.length-1 && j < p.length-1) {
                    i++;
                    j++;
                }
            }
            if (j == p.length-1){
                return ps;
            }
            ps += 1;

        }
        return -1;
    }
    public static void main(String[] args) {
    //    System.out.println(strStr("hello" ,"ll"));
    //    System.out.println(111);
        String s = "   Addd ";
        String n = s.trim();
        System.out.println(n);
    }
}
